<div class="form-group single_query col-xs-12 bool_query" (mouseover)="show_hidden_btns($event);" (mouseout)="hide_hidden_btns($event);">
	<div class="action-btn-group bool-btn-group">
		<a href="javascript:void(0)" (click)="removeInQuery(query.id)" class="btn btn-grey delete-nested-query">
			<i class="fa fa-times"></i>
		</a>
	</div>
	<div class="row m-b15 nested-first">
		<div class="col-xs-12 nested-container">
			<button (click)="addSubQuery(query.id)" class="btn btn-default nested-query">
				<i class="fa fa-plus"></i> Sub Query
			</button>
			<div class="col-xs-6">
				<editable [editableField]="queryList.boolQuery[query.boolparam]" [editableModal]="query.boolparam" [editPlaceholder]="'bool'" [editableInput]="'select'" [selectOption]="queryList.boolQuery" (callback)="booleanChange($event)"></editable>
				<!-- <select class="form-control form-element" [(ngModel)]="query.boolparam" (change)="exeBuild();">
					<option *ngFor="let oo of queryList.boolQuery, let i=index" [value]="i">{{oo}}</option>
				</select> -->
			</div>
			<div class="col-xs-6" *ngIf="queryList.boolQuery[query.boolparam] == 'should'">
				<div class="form-group form-element">
					<input type="text" class="form-control" placeholder="Minimum should match" [(ngModel)] = "query.minimum_should_match"  (keyup)="exeBuild();" />
				</div>
			</div>
		</div>
	</div>
	<div class="row s-12" *ngIf="(joiningQuery && joiningQuery.length > 1)">
		<div class="checkbox">
			<input id="cb-1" type="checkbox" [(ngModel)]="showJoiningQuery" (change)="joiningQueryChange(0)" autocomplete="off">
            <label for="cb-1">Add Joining Query</label>
        </div>
		<div class="nested-container" *ngIf="showJoiningQuery" style="padding-left: 15px">
			<div class="col-xs-4 form-group form-element">
				<editable 
					class="select-joining-query"
					[editableField]="joiningQuery[joiningQueryParam]"
					[editPlaceholder]="'select-joining-query'"
					[editableInput]="'select2'"
					[selectOption]="joiningQuery"
					[selector]="'select-joining-query'"
					[informationList]="informationList"
					[showInfoFlag]="true"
					[searchOff]="true"
					(setDocSample)="setDocSampleEve($event);"
					(callback)="joiningQueryChange($event)"></editable>
			</div>
			<div *ngIf="joiningQuery[joiningQueryParam] == 'nested'">
				<div class="col-xs-4 form-group form-element">
					<input type="text" class="form-control" placeholder="path" [(ngModel)] = "query.path"  (keyup)="exeBuild();" />
				</div>
				<div class="col-xs-4 form-group form-element">
					<input type="text" class="form-control" placeholder="score_mode" [(ngModel)] = "query.score_mode"  (keyup)="exeBuild();" />
				</div>
			</div>
			<div *ngIf="joiningQuery[joiningQueryParam] == 'has_child'">
				<div class="col-xs-4 form-group form-element">
					<input type="text" class="form-control" placeholder="type" [(ngModel)] = "query.type"  (keyup)="exeBuild();" />
				</div>
				<div class="col-xs-4 form-group form-element">
					<input type="text" class="form-control" placeholder="score_mode" [(ngModel)] = "query.score_mode"  (keyup)="exeBuild();" />
				</div>
			</div>
			<div *ngIf="joiningQuery[joiningQueryParam] == 'has_parent'">
				<div class="col-xs-4 form-group form-element">
					<input type="text" class="form-control" placeholder="parent type" [(ngModel)] = "query.parent_type"  (keyup)="exeBuild();" />
				</div>
			</div>
			<div *ngIf="joiningQuery[joiningQueryParam] == 'parent_id'">
				<div class="col-xs-4 form-group form-element">
					<input type="text" class="form-control" placeholder="type" [(ngModel)] = "query.type"  (keyup)="exeBuild();" />
				</div>
				<div class="col-xs-4 form-group form-element">
					<input type="text" class="form-control" placeholder="id" [(ngModel)] = "query.xid"  (keyup)="exeBuild();" />
				</div>
			</div>
		</div>
	</div>
	<div class="internvalQuery">
		<form class="row m-0"
		 *ngFor="let queryIn of query.internal, let internalIndex=index"
		 >
			<single-query 
				[mapping]="mapping"
				[types]="types"
				[selectedTypes]="selectedTypes" 
				[result]="result" 
				[config]="config" 
				[query]="queryIn" 
				[queryList]="queryList"
				[internalIndex]="internalIndex"
				[queryIndex]="query.id"
				[internal]="query.internal"
				[buildQuery]="buildQuery"
				[buildInsideQuery]="buildInsideQuery"
				[buildSubQuery]="buildSubQuery"
				[createQuery]="createQuery"
				[setQueryFormat]="setQueryFormat"
				[editorHookHelp]="editorHookHelp"
				[urlShare]="urlShare"
				[boolQueryName]="queryList.boolQuery[query.boolparam]"
				[joiningQuery]="joiningQuery"
				[joiningQueryParam]="joiningQueryParam"
				(setDocSample)="setDocSampleEve($event);">
			</single-query>
		</form>
	</div>
	<div class="col-xs-12 add_condition_row">
		<button class="btn btn-default add_condition" (click)="addQuery(query);"><i class="fa fa-plus"></i> Conditions</button>
	</div>
	<div class="subQuery col-xs-12">
		<form class="row m-0" *ngFor="let queryIn of result.resultQuery.result">
			<div *ngIf="queryIn.parent_id != 0 && queryIn.parent_id == query.id">
				<bool-query 
					[mapping]="mapping"
					[types]="types"
					[selectedTypes]="selectedTypes" 
					[result]="result" 
					[config]="config" 
					[query]="queryIn" 
					[queryList]="queryList"
					[addQuery]="addQuery"
					[addBoolQuery]="addBoolQuery"
					[removeQuery]="removeQuery"
					[queryFormat]="queryFormat"
					[buildQuery]="buildQuery"
					[buildInsideQuery]="buildInsideQuery"
					[buildSubQuery]="buildSubQuery"
					[createQuery]="createQuery"
					[setQueryFormat]="setQueryFormat"
					[editorHookHelp]="editorHookHelp"
					[urlShare]="urlShare"
					[joiningQuery]="joiningQuery"
					[joiningQueryParam]="joiningQueryParam"
					(setDocSample)="setDocSample($event);" >
				</bool-query>
			</div>
		</form>
	</div>
</div>